package com.travel.ticket.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.travel.ticket.entity.SpuRelationAttrEntity;
import com.travel.ticket.service.SpuRelationAttrService;
import com.travel.common.utils.PageUtils;
import com.travel.common.utils.R;



/**
 * 
 *
 * @author lxw
 * @email lxw@gmail.com
 * @date 2024-01-24 16:51:15
 */
@RestController
@RequestMapping("ticket/spurelationattr")
public class SpuRelationAttrController {
    @Autowired
    private SpuRelationAttrService spuRelationAttrService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("ticket:spurelationattr:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = spuRelationAttrService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{relationId}")
    //@RequiresPermissions("ticket:spurelationattr:info")
    public R info(@PathVariable("relationId") Integer relationId){
		SpuRelationAttrEntity spuRelationAttr = spuRelationAttrService.getById(relationId);

        return R.ok().put("spuRelationAttr", spuRelationAttr);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("ticket:spurelationattr:save")
    public R save(@RequestBody SpuRelationAttrEntity spuRelationAttr){
		spuRelationAttrService.save(spuRelationAttr);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("ticket:spurelationattr:update")
    public R update(@RequestBody SpuRelationAttrEntity spuRelationAttr){
		spuRelationAttrService.updateById(spuRelationAttr);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("ticket:spurelationattr:delete")
    public R delete(@RequestBody Integer[] relationIds){
		spuRelationAttrService.removeByIds(Arrays.asList(relationIds));

        return R.ok();
    }

}
